# name : R arsenal tableby with controls and labels
# key : arsenal.tableby.with.controls.labels
# key : tableby@arsenal.full
# contributor: Shuguang
# expand-env: ((yas-wrap-around-region 'nil))
# --
${1:my_controls} <- tableby.control(
  test = FALSE,
  total = T,
  numeric.test = "kwt", cat.test = "chisq",
  numeric.stats = c("N", "meansd", "median", "range"),
  cat.stats = c("N", "countpct"),
  stats.labels = list(
    N = "n",
    meansd = "Mean (SD)",
    median = "Median",
    range = "Min - Max"),
  digits = 1L)

${2:bsl_labels} <- list(
  AGE = "Age, yrs",
  SEX = "SEX",
  HT = "Height, cm",
  WT = "Weight, kg")

${3:tb_summary} <- tableby(${4:group} ~ ${5:x + y},
                   data = tb_ppd_twoarm,
                   control = $1)

knitr::kable(
         summary($3, labelTranslations = $2, text = TRUE),
         caption = "${6:caption}")
